Skip to content

Fix: escape shortcut key overriding each other#49

Merged
neil-marcellini merged 2 commits into
Expensify:mainfrom
bernhardoj:fix/overlapped-escape-shortcut
Jun 3, 2025
Merged

Fix: escape shortcut key overriding each other#49
neil-marcellini merged 2 commits into
Expensify:mainfrom
bernhardoj:fix/overlapped-escape-shortcut

Conversation

@bernhardoj

@bernhardoj bernhardoj commented Jun 3, 2025

Copy link
Copy Markdown
Contributor

Same root cause as Expensify/App#18480 and same solution too.

Related issue: Expensify/App#61622

Added Shift + ESC shortcut to the example app. Both ESC and Shift + ESC works fine.

w.mp4

@github-actions

github-actions Bot commented Jun 3, 2025

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@bernhardoj

Copy link
Copy Markdown
Contributor Author

I have read the CLA Document and I hereby sign the CLA

CLABotify added a commit to Expensify/CLA that referenced this pull request Jun 3, 2025
Comment thread src/KeyCommand/index.js Outdated
// https://github.com/Expensify/App/issues/18480
const strictIndex = _.findIndex(commands, item => (
(item.input === json.input && matchesModifierFlags(item))
((item.input === json.input || (matchesEscape(item))) && matchesModifierFlags(item))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This technically happens to every non single letter input, but I only added it for escape for now. Let me know if I should handle them all.

@s77rt s77rt Jun 3, 2025

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I understand the logic here. Why are item.input and json.input not equal? (and what are their values)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still trying to understand the bug. Here is what I think is going: After you press ESC, we look for an exact (strict) match and we fail and fallback for loose match and we end up with the listener for SHIFT + ESC (because it's somehow first in the list). Does that sound about right? If so I think we should add a condition to handle exact ESC key combination i.e.:

    const strictIndex = _.findIndex(commands, item => (
        (item.input === json.input && matchesModifierFlags(item))
        || (matchesEnter(item) && matchesModifierFlags(item))
        || (matchesEscape(item) && matchesModifierFlags(item))
    ));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh it's exactly the same logic your are making XD

Can you just rewrite that way as I think it's a little more readable

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haha, I'm trying to keep it short. Updated.

@bernhardoj

Copy link
Copy Markdown
Contributor Author

cc: @s77rt for review

@s77rt

s77rt commented Jun 3, 2025

Copy link
Copy Markdown
Member

cc @neil-marcellini please merge this

@neil-marcellini neil-marcellini merged commit f39fd73 into Expensify:main Jun 3, 2025
1 check passed
@os-botify

os-botify Bot commented Jun 3, 2025

Copy link
Copy Markdown
Contributor

🚀 Published to npm in 1.0.14 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants